package com.inspur.resourcequery.adapter;

import java.util.List;

import com.inspur.resourcequery.R;
import com.inspur.resourcequery.model.ResData;



import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ResListAdapter  extends BaseAdapter {

	private List list;
	private Context mContext;
	
	public ResListAdapter(Context context, List list) {
		mContext = context;
		this.list = list;
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder = null;
//		if(convertView == null){
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(R.layout.reslist_item, null);
			
			viewHolder.tvName = (TextView)convertView.findViewById(R.id.tv_name);
			viewHolder.tvIndustry = (TextView)convertView.findViewById(R.id.tv_industry);
			convertView.setTag(viewHolder);
//		} else {
//			viewHolder = (ViewHolder)convertView.getTag();
//		}
		ResData model = (ResData)list.get(position);
		viewHolder.tvName.setText(model.getName());
		viewHolder.tvIndustry.setText(model.getCityName());
		return convertView;
	}

	final static class ViewHolder{
		TextView tvName;
//		TextView tvType;
		TextView tvIndustry;
	}
}
